-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Solid particles start and lifetime #17501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Solid particles start and lifetime #17501
Conversation
…p methods in SolidParticleSystem - Introduced `lifeTime` and `age` properties in `SolidParticle` to manage particle lifespan. - Updated particle age during the rendering loop in `SolidParticleSystem` and checked against `lifeTime` for particle death. - Added `start` and `stop` methods to control the particle system's emission and update loop, with an observer for rendering updates. - Included `updateSpeed` property for customizable animation speed.
|
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
|
Snapshot stored with reference name: Test environment: To test a playground add it to the URL, for example: https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/17501/merge/index.html#WGZLGJ#4600 Links to test babylon tools with this snapshot: https://playground.babylonjs.com/?snapshot=refs/pull/17501/merge To test the snapshot in the playground with a playground ID add it after the snapshot query string: https://playground.babylonjs.com/?snapshot=refs/pull/17501/merge#BCU1XR#0 |
|
Devhost visualization test reporter: |
|
Visualization tests for WebGPU |
|
WebGL2 visualization test reporter: |
Add start/stop lifecycle and age/lifetime support to SolidParticleSystem
Summary
This PR adds lifecycle management capabilities to
SolidParticleSystemto align with the architecture of standardParticleSystem, while maintaining backward compatibility with the existing SolidParticleSystem behavior-agnostic design.Changes
New Features
1. Lifecycle Management (
start()andstop()methods)start(delay?: number): Starts the particle system and begins automatic updatesbuildMesh(),initParticles(), andsetParticles()in sequenceonBeforeRenderObservablefor automatic frame-by-frame updatesstop(): Stops the particle systemstartedandstoppedgetters: Read-only properties to check system state2. Age and Lifetime Support
age: Current age of the particle (starts at 0, increments each frame)lifeTime: Maximum lifetime of the particle (defaults toInfinityfor infinite life)Infinityby default to maintain backward compatibility (particles never die by default)isFinite(lifeTime))3. Update Speed Management
updateSpeed: Public property (default: 0.01) matchingBaseParticleSystemarchitecture_scaledUpdateSpeed: Internal scaled value usinggetAnimationRatio()for FPS independenceImplementation Details
Automatic Update Loop
When
start()is called, the system automatically registers toscene.onBeforeRenderObservable:This ensures particles are updated every frame without manual
setParticles()calls.Age and Lifetime Logic
In
setParticles(), the system now:particle.ageby_scaledUpdateSpeedeach frame (only when started)age >= lifeTimeonly whenlifeTimeis finiteparticle.alive = falsewhen lifetime is reached (no automatic recycling, as SolidParticleSystem uses fixed arrays)Backward Compatibility
lifeTime = Infinity: Particles never die by default, maintaining original behaviorUsage Examples
Basic Usage (Infinite Lifetime - Default Behavior)
Usage with Lifetime Management
Breaking Changes
None - All changes are backward compatible: